package com.example.fragmentTest2;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class DetailsFragment extends Fragment {

	public static DetailsFragment newInstance(int position){
		
		DetailsFragment frag = new DetailsFragment();
		
		Bundle b = new Bundle();
		b.putInt("pos", position);
		frag.setArguments(b);
		
		return frag;
	}
	
	public int getPosition(){
		return getArguments().getInt("pos");
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		
		View v = inflater.inflate(R.layout.detail_layout, container, false);
		
		TextView tv = (TextView) v.findViewById(R.id.detailText);
		tv.setText(BookInfo.DETAILS[getPosition()]);
		
		return v;
	}

}
